package com.example.demo.dao;


import java.util.List;

import org.apache.shiro.session.Session;

import com.example.demo.mapper.SessionMapper;
import com.example.demo.util.SerializableUtils;

/**
 * jdbc操作Session的实现类
 * <p>@author Henry.Y</p>
 * <p>@date 2019-08-30</p>
 */
public class SessionDao extends BaseDao implements SessionMapper{

	public int createSession(String sqlId,Session session){
		com.example.demo.entity.Session sessionEntity= new com.example.demo.entity.Session();
		sessionEntity.setId(String.valueOf(session.getId()));
		sessionEntity.setSession(SerializableUtils.serialize(session));
		return operateInsertSql(sqlId,sessionEntity);
	}
	
	public int deleteSession(String sqlId,String sessionId){
		
		return operateInsertSql(sqlId,sessionId);
	}
	
	public int updateSession(String sqlId,Session session){
		com.example.demo.entity.Session sessionEntity= new com.example.demo.entity.Session();
		sessionEntity.setId(String.valueOf(session.getId()));
		sessionEntity.setSession(SerializableUtils.serialize(session));
		return operateUpdateSql(sqlId,sessionEntity);
	}
	
	public com.example.demo.entity.Session selectSession(String sqlId,String sessionId){
		
		return (com.example.demo.entity.Session)operateSelectOneSql(sqlId,sessionId);
	}
	
    @SuppressWarnings("unchecked")
	public List<String> selectSessionByLimit(String sqlId,com.example.demo.entity.Session session){
		
		return (List<String>)operateSelectSql(sqlId,session);
	}
}
